package cn.pku.ss.fa.sessionbean;

import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import cn.pku.ss.fa.bean.*;
import cn.pku.ss.fa.entity.*;

@Stateless
public class CityDAO implements CityDAORemote {

	@PersistenceContext
	protected EntityManager manager;
	
	public void insertCities() {
		Province province1 = new Province("JiangSu");
		Province province2 = new Province("GuangXi");
		Province province3 = new Province("HuBei");
		Province province4 = new Province("ShanDong");
		
		manager.persist(province1);
		manager.persist(province2);
		manager.persist(province3);
		manager.persist(province4);
		
		City city1 = new City("Guilin");
		city1.setProvince(province2);
		City city2 = new City("Nanning");
		city2.setProvince(province2);
		City city3 = new City("Nanjing");
		city3.setProvince(province1);
		City city4 = new City("Wuxi");
		city4.setProvince(province1);
		City city5 = new City("Shijiazhuan");
		city5.setProvince(province3);
		City city6 = new City("Baoding");
		city6.setProvince(province3);
		City city7 = new City("Jinan");
		city7.setProvince(province4);
		City city8 = new City("Qingdao");
		city8.setProvince(province4);
		
		manager.persist(city1);
		manager.persist(city2);
		manager.persist(city3);
		manager.persist(city4);
		manager.persist(city5);
		manager.persist(city6);
		manager.persist(city7);
		manager.persist(city8);
		
		
		
	}
}
